package com.wyp168.leetcode;

import com.wyp168.leetcode.treenode.TreeNode;

/**
 * @ClassName TreeNodeIsSymmetric
 * @Description TODO
 * @Author wyp168
 * @Date 2022/7/20 20:27
 */
public class TreeNodeIsSymmetric {
    public static void main(String[] args) {

    }

    public static boolean isSymmetric(TreeNode root) {
        return check(root,root);
    }

    public static boolean check(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if (p == null || q == null) {
            return false;
        }
        return p.val == q.val && check(p.left,q.right) && check(p.right,q.left);
    }
}
